/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package co.edu.unal.bioingenium.kbmed.knowledge.similarity.metrics;

import co.edu.unal.bioingenium.kbmed.knowledge.hierarchy.HierarchyService;
import co.edu.unal.bioingenium.kbmed.knowledge.similarity.InformationContentService;

/**
 * sim (p1,p2)= IC(LCS(p1,p2))
 * @author lariverosc
 * TODO all values in the same hierarchy are equal, so the leastcommon subsummer has a bug??
 */
public class Resnick implements SemanticSimilarity {

    private HierarchyService graphManager;
    private InformationContentService informationContentValues;

    /**
     * 
     */
    public Resnick() {
        this.graphManager = HierarchyService.getInstance();
        informationContentValues = InformationContentService.getInstance();
    }

    /**
     * 
     * @param conceptId1
     * @param conceptId2
     * @param category
     * @return
     */
    @Override
    public float getSimilarity(String conceptId1, String conceptId2, String category) {
        String lcs = graphManager.getLeastCommonSubsummer(conceptId1, conceptId2, category);
        return informationContentValues.getInformationContentValue(category, lcs);
    }
}
